package com.example.homeworktagger.controller;

import com.example.homeworktagger.service.HomeworkTagService;
import com.example.homeworktagger.service.HomeworkTagService.TagResult;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequiredArgsConstructor
public class HomeworkController {

    private final HomeworkTagService homeworkTagService;

    @GetMapping("/")
    public String index() {
        return "index";
    }

    @PostMapping("/submit")
    public String submitHomework(@RequestParam String homeworkContent, Model model) {
        TagResult result = homeworkTagService.generateTags(homeworkContent);
        model.addAttribute("result", result);
        return "result";
    }
} 